@extends('admin.layout')
@section('content')
<!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                分类管理
                <small>修改</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 后台主页</a></li>
                <li><a href="#">分类管理</a></li>
                <li class="active">修改分类</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">快速修改分类</h3>
                        </div><!-- /.box-header -->
                       
                       
                        <!-- form start -->   
                        <form role="form" action="{{ url('/admin/cate') }}/{{ $data -> id }}"  method="post" enctype="multipart/form-data">
                        {{ method_field('PUT') }}
                        {{  csrf_field() }}                         

                            <div class="box-body">

                            @if(session('info'))
                            <div class="alert alert-warning alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4><i class="icon fa fa-warning"></i> 警告!</h4>
                                 <ul>
                                    {{ session('info') }}
                                 </ul>
                                </div>                              
                            @endif

                            @if (count($errors) > 0)
                                <div class="alert alert-warning alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4><i class="icon fa fa-warning"></i> 警告!</h4>
                                 <ul>
                                     @foreach ($errors->all() as $error)
                                     <li>{{ $error }}</li>
                                     @endforeach
                                 </ul>
                                </div>
                            @endif
                                <div class="form-group">
                                    <label for="exampleInputName">分类列表页顶部图片</label>
                                    <input name = 'headimg' value = "{{ old('headimg') }}" type="file" id="exampleInputEmail1">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputName">分类名称</label>
                                    <input name = 'name' value = "{{ $data -> name }}" type="text" class="form-control" id="exampleInputEmail1"
                                           placeholder="请输入分类名">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputName">父分类</label>
                                        <select name="pid" class="form-control">

                                        <option value= "0">根分类</option>
                                        @foreach($allData as $cate)
                                        <option

                                        @if($cate -> id == $data -> pid)
                                            selected = "selected" disabled="true" style="background:#ccc;"
                                        @endif
                                        @if($cate -> id == $data -> id)
                                            disabled="true" style="background:red"
                                        @endif

                                        value="{{ $cate -> id }}">{{ $cate -> name }}</option>
                                        @endforeach
                                        </select>
                                       
                                </div>

                                <div class="form-group">
                                    <label for="exampleInputName">选择显示位置</label><br/>
                                   <input type="hidden" value="{{$checked=$data -> nav_position}}">
                                   <input type="hidden" value="{{$checked1=$data -> menu_position}}">
                                   
                                    <input name = 'nav_position' value = "1" type="checkbox"
                                        @if($checked)
                                            checked 
                                        @endif
                                    >首页导航栏&nbsp
                                   
                                    <input name = 'menu_position' value = "1" type="checkbox" 
                                    @if($checked1)
                                            checked 
                                        @endif
                                    >MENU菜单栏

                                </div>
                               
                                </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">更新</button>
                                <button type="submit" class="btn btn-default">重写</button>
                            </div>
                        </form>
                    </div><!-- /.box -->                
               
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
@endsection